﻿using System;
class SumOfnNumbers
{
    static void Main()
    {
        int numberofnumbers;
        int sum = 0;
        int number;
        Console.Write("Please input first number: ");
        while (true)
        {
            try
            {
                numberofnumbers = int.Parse(Console.ReadLine());
                break;
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message + "\nPlease re-enter first number:");
            }
        }
        Console.WriteLine("please enter {0} numbers:", numberofnumbers);
        for (int counter = 1; counter <= numberofnumbers; counter++)
        {
            Console.Write("Please enter number {0}: ", counter);
            while (true)
            {
                try
                {
                    number = int.Parse(Console.ReadLine());
                    break;
                }
                catch (Exception ex)
                {
                    Console.Write(ex.Message + "\nPlease re-enter first number:");
                }
            }
            sum = sum + number;
        }
        Console.WriteLine("The sum of all entered numbers is: {0}", sum);
        Console.ReadLine();
    }
}

